package com.blockmeta.bbs.businesslibrary.business;


import com.blockmeta.bbs.businesslibrary.websocket.ConnectManager;
import com.blockmeta.bbs.businesslibrary.websocket.IFlowManager;
import com.blockmeta.bbs.businesslibrary.websocket.QuoteCenter;

import buf.Return;

public class DataManager extends BaseManager implements IFlowManager {

    private static DataManager m_dataManager = null;

    protected BBSManager m_BBSManager;
    protected QuoteCenter m_quoteCenter;

    public DataManager() {
        super();

        m_BBSManager = new BBSManager();
        m_quoteCenter = new QuoteCenter();

        m_dataManager = this;
    }

    public static DataManager getDataManager() {
        if (m_dataManager == null) {
            synchronized (DataManager.class) {
                if (m_dataManager == null) {
                    m_dataManager = new DataManager();
                }
            }
        }
        return m_dataManager;
    }

    public BBSManager getCommentManager() {
        return m_BBSManager;
    }


    public QuoteCenter getQuoteCenter()
    {
        return m_quoteCenter;
    }

    @Override
    public void onCreate() {
        m_quoteCenter.onCreate();
    }

    @Override
    public void onConnectCreate() {
        m_quoteCenter.onConnectCreate();
    }

    public void processPacket(Return.NormalReturn packet, ConnectManager connectManager )
    {

        switch (packet.getEvent())
        {
            case "kline_list":
            case "tickers":
            case "trade_list":
            case "notify_res":
            case "depth":
                m_quoteCenter.processPacket(packet, connectManager);
                break;
        }
    }


}
